using System;
using System.Collections;
using GameFramework.DataTable;
using Unity.VisualScripting;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Data Table")]
    [UnitSurtitle("Destroy")]
    public sealed class DestroyDataTable : DataTableUnit
    {
        [Serialize]
        [Inspectable, UnitHeaderInspectable]
        [TypeFilter(typeof(DataRowBase))]
        public System.Type DataTableType { get; private set; }
        
        [PortLabelHidden]
        [DoNotSerialize]
        public ValueOutput Result { get; private set; }
        protected override void Definition()
        {
            base.Definition();
            Result = ValueOutput<bool>(nameof(Result));
        }

        protected override ControlOutput In(Flow flow)
        {
            bool result = Target?.DestroyDataTable(DataTableType) ?? false;
            flow.SetValue(Result, result);
            return base.In(flow);
        }
    }
}